package com.hilton.tigershark.view;

import android.content.Context;
import android.content.pm.PackageManager;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.WebView;

import com.hilton.tigershark.BrowserSettings;

public class CustomizedWebviewFactory implements WebviewFactory {
    private final Context mContext;

    public CustomizedWebviewFactory(Context context) {
        mContext = context;
    }

    protected WebView instantiateWebView(AttributeSet attrs, int defStyle) {
        return new CustomizedWebview(mContext, attrs, defStyle);
    }
    @Override
    public WebView createWebview() {
        WebView w = instantiateWebView(null, android.R.attr.webViewStyle);
        initWebViewSettings(w);
	return w;
    }

    @Override
    public WebView createSubWebview() {
	return createWebview();
    }
    
    protected void initWebViewSettings(WebView w) {
        w.setScrollbarFadingEnabled(true);
        w.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
        w.setMapTrackballToArrowKeys(false); // use trackball directly
        // Enable the built-in zoom
        w.getSettings().setBuiltInZoomControls(true);
        // Add this WebView to the settings observer list and update the
        // settings
        final BrowserSettings s = BrowserSettings.getInstance();
        s.addObserver(w.getSettings()).update(s, null);
    }
}